#include <gtest/gtest.h>
#include "core/regions/end_point_provider.h"
#include "core/profile/default_profile.h"
#include "core/default_acs_client.h"
#include "Ecs/2014-05-26/DescribeRegionsRequest.h"
#include "Ecs/2014-05-26/DescribeRegionsResponse.h"

using namespace aliyun;


TEST(ecs_2014_05_26, Demo) {
  EndpointProvider::SetDefaultEndpoints();
  DefaultProfile *default_profile = DefaultProfile::GetProfile("cn-hangzhou", "your key", "you secret");
  DefaultAcsClient default_acs_client(default_profile);
  Ecs::DescribeRegionsRequest request;
  Ecs::DescribeRegionsResponse response;
  request.SetMethod("GET");
  request.SetAcceptFormat("JSON");
  if(default_acs_client.GetAcsResponse(&request, &response)) {
    ASSERT_STREQ("", response.GetCode().c_str());
  } else {
    ASSERT_STRNE("", response.GetCode().c_str());
  }
  #if 1
  printf("code:%s\n", response.GetCode().c_str());
  printf("message:%s\n", response.GetMessage().c_str());
  std::vector<Ecs::DescribeRegionsResponse::Region> regions = response.GetRegions();
  printf("regions length:%d\n", (int)regions.size());
  for(size_t i = 0; i < regions.size(); i++) {
    printf("RegionId:%s\n", regions[i].GetRegionId().c_str());
    printf("LocalName:%s\n", regions[i].GetLocalName().c_str());
  }
  #endif
  DefaultProfile::ReleaseProfile(default_profile);
}

// end of file
